//
//  SMHomeMiddleTableViewCell.m
//  ShoppingMall
//
//  Created by Demon on 2018/3/22.
//  Copyright © 2018年 Demon. All rights reserved.
//

#import "SMHomeMiddleTableViewCell.h"

@interface SMHomeMiddleTableViewCell ()

@property (weak, nonatomic) IBOutlet UIButton *btn1;
@property (weak, nonatomic) IBOutlet UIButton *btn2;
@property (weak, nonatomic) IBOutlet UIButton *btn3;
@property (weak, nonatomic) IBOutlet UIButton *btn4;
@property (weak, nonatomic) IBOutlet UIButton *btn5;
@property (weak, nonatomic) IBOutlet UIButton *btn6;

@property (nonatomic, strong) NSArray *btnArray;
@property (nonatomic, strong) NSArray *brands;

@end

@implementation SMHomeMiddleTableViewCell

- (void)setHomeMiddleCellModel:(NSArray<SMBrandModel *> *)brands {
    self.brands = brands;
    for (int i = 0; i < brands.count; i++) {
        SMBrandModel *brandModel = brands[i];
        UIButton *button = self.btnArray[i];
        [button sd_setBackgroundImageWithURL:[NSURL URLWithString:brandModel.imgurl] forState:UIControlStateNormal];
    }
}

- (IBAction)btnClick:(UIButton *)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(homeCellWithName:h5url:dataurl:)]) {
        SMBrandModel *model = self.brands[sender.tag - 1];
        [self.delegate homeCellWithName:model.name h5url:model.h5url dataurl:model.dataurl];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (NSArray *)btnArray {
    if (!_btnArray) {
        _btnArray = @[self.btn1,self.btn2,self.btn3,self.btn4,self.btn5,self.btn6];
    }
    return _btnArray;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
